#ifdef __USE_CMSIS
#include "LPC17xx.h"
#endif

#include <cr_section_macros.h>
#include <NXP/crp.h>

__CRP const unsigned int CRP_WORD = CRP_NO_CRP ;

#include <stdio.h>
#include <stdlib.h>
#include <string.h>

#include "sysconfig.h"
#include "i2c.h"
#include "lcd03.h"

#define DELAY1 20000
#define DELAY2 25000
// ! SEMIHOSTING
int main(void)
{
	int i,c;
	char rpm[16];

	sysconfig();

	I2C1_Init();

	lcdData = (char*)malloc(sizeof(char)*64);
    dataPtr = 0;
	LCD03_CLEAR_HOME()
	 for(i=0; i < DELAY1; i++);
	LCD03_BACK_ON()
	 for(i=0; i < DELAY1; i++);
	LCD03_SET_CURSORXY(2, 2)
	 for(i=0; i < DELAY1; i++);
	LCD03_MSG("RPM1 = ")
	 for(i=0; i < DELAY1; i++);
	LCD03_SET_CURSORXY(3, 2)
	 for(i=0; i < DELAY1; i++);
	LCD03_MSG("RPM2 = ")
	 for(i=0; i < DELAY1; i++);
	LCD03_HIDE_CURSOR()
	 for(i=0; i < DELAY1; i++);

    c = 0;
	while(1)
	{
		LCD03_SET_CURSORXY(2, 9)
	      for(i=0; i < DELAY2; i++);
		sprintf(rpm,"%4d",c);
		LCD03_MSG(rpm)
	      for(i=0; i < DELAY2; i++);

		LCD03_SET_CURSORXY(3, 9)
	      for(i=0; i < DELAY2; i++);
		sprintf(rpm,"%4d",c);
		LCD03_MSG(rpm)
	      for(i=0; i < DELAY2; i++);
		c++ ;
	}

}

